<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
    <meta charset="UTF-8">
    <title>History Task</title>
    <span th:include="common/templates :: common-css-js"></span>
    <span th:include="common/templates :: init-menu"></span>
    <span th:include="common/templates :: bootstrap-table"></span>
</head>
<body>
<div th:replace="common/templates :: header"></div>
<div class="container">

    <div class="page-header">
        <div class="h3">HISTORY TASK</div>
    </div>
    <table id="records-info"></table>
</div>
</body>
<script th:inline="text">
    $('#records-info').bootstrapTable({
        url: "[[@{/HistoryTask/current}]]",//请求数据url
        showRefresh: true,
        smartDisplay: true,
        showToggle: true,
        paginationPreText: '上一页',
        paginationNextText: '下一页',
        pagination: true,//分页
        pageNumber: 1,
        pageSize: 15,
        pageList: [10, 20, 30, 50, 'all'],//分页步进值
        search: true, //显示搜索框
        columns: [
            {
                field: 'taskId',
                title: '任务ID',
            },
            {
                field: 'businessKey',
                title: '业务Key',
            },
            {
                field: 'creatorName',
                title: '完成人',
            },
            {
                field: 'processDefineName',
                title: '流程名',
            },

            {
                field: 'taskName',
                title: '任务名',
            },
            {
                field: 'comment',
                title: '批注',
            },
            {
                field: 'lastCommit',
                title: '操作',
                formatter: function (value, row, index) { // 单元格格式化函数

                    var taskId = row['taskId'];

                    if (value != undefined && value != null) {
                        return "<a class='btn btn-default btn-sm btn-cancel' data-id='" + taskId + "'>撤回</a>"
                    }
                    return "";
                }
            },
        ]
    })

    $("#records-info").on("click", ".btn-cancel" ,function () {
        var taskId = $(this).attr("data-id");

        $.post("[[@{/Task/callBack/}]]"+taskId,function (result) {
            if(result['code']==200){
                $("#records-info").bootstrapTable("refresh");
                alert("撤回成功!");
            }
        })

    })

</script>
</html>